/*
 * @Author: dvlproad
 * @Date: 2023-12-11 09:48:39
 * @LastEditors: dvlproad
 * @LastEditTime: 2023-12-13 11:37:35
 * @Description: 
 */

import 'package:flutter/material.dart';

import './model/entity.dart';
import './widget/main_card_widget.dart';
import './request/card_request_util.dart';

class CardHomePage1 extends StatefulWidget {
  const CardHomePage1({Key? key}) : super(key: key);

  @override
  _CardHomePage1State createState() => _CardHomePage1State();
}

class _CardHomePage1State extends State<CardHomePage1> {
  List<CardEntity>? _cardList;

  @override
  initState() {
    super.initState();
    _requestCardsData();
  }

  void _requestCardsData() async {
    _cardList = await CardRequestUtil.loadCardList();
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    if (_cardList == null || _cardList!.isEmpty) {
      return Container(
        alignment: Alignment.center,
        child: const Text(
          "Loading...",
        ),
      );
    }

    return Stack(
      children: <Widget>[
        CardStackWidget(
          cardList: _cardList!,
          offset: 8,
          cardCount: 2,
        )
      ],
    );
  }
}
